package db;

import java.io.IOException;

import org.jdom.*;

/**
 * In the moment this main class only does the parsing, later on it should add
 * the objects to the database too. test
 * 
 * @author markus
 * @author antonia
 * 
 */
public class Parse2Db {

	static Controller controller = null;
	static Parser parser = null;
	static DB2Query query = null;
	static boolean debug = false;

	/**
	 * @param args
	 * @throws IOException
	 * @throws JDOMException
	 * @org.JUnit.Test
	 */
	public static void main(String[] args) throws JDOMException, IOException {
		controller = new Controller();
		parser = new Parser(controller);

		parser.parseXml("countries1990.xml");
		parser.parseXml("countries1996.xml");
		parser.parseXml("countries1999.xml");
		parser.parseXml("countries2000.xml");
		parser.parseXml("countries2003.xml");

		parser.parseContinent("countryToContinent.lst");
		parser.parseFlagMap("countryFlagMapLocation.lst");
		parser.parseAbbreviation("abbreviation.lst");

		parser.parseXml("cities.xml");

		// special behaviour after cities.xml is parsed
		parser.parseXml("countries2003.xml");
		
//		for (Country c : controller.getCountries()) {  //testest
//			System.out.println(c.getShortName());
//			for (Place p: controller.getPlaces()) {
//				if (p.isPort() && p.getCountry().getShortName().equals(c.getShortName())) {
//					System.out.println(" " +p.getName());
//				}
//			}
//		}
		
		query = new DB2Query(controller);
		query.fillDB();
		
		LogDat.getInstance().close();
		System.out.println("Done! ");
	}
}
